//-------------------------------------------------------------------------
//
//  Copyright (c) 1999 Cornell University
//  Computer Systems Laboratory
//  Cornell University, Ithaca, NY 14853
//  All Rights Reserved
//
//  Permission to use, copy, modify, and distribute this software
//  and its documentation for any purpose and without fee is hereby
//  granted, provided that the above copyright notice appear in all
//  copies. Cornell University makes no representations
//  about the suitability of this software for any purpose. It is
//  provided "as is" without express or implied warranty. Export of this
//  software outside of the United States of America may require an
//  export license.
//
//  $Id: fp.v,v 1.1.1.1 2003/01/16 19:49:43 heinrich Exp $
//
//-------------------------------------------------------------------------

`include "mips.h"

module fp (RSbus, RTbus, SEL, HI, LO);
input	[31:0]	RSbus;			// rs operand input
input 	[31:0]	RTbus;			// rt operand input
input	[7:0]	SEL;			// Operation select

// HI, LO registers
output	[31:0]	HI;
reg		[31:0]	HI;
output	[31:0]	LO;
reg		[31:0]	LO;

//--------------------------------------------------------------------

// Perform FP operation
always @(RSbus or RTbus or SEL) begin
   // Instructions Supported
   case (SEL)
	 `select_fp_multu:
      `select_fp_mult:   LO = ((RSbus * RTbus) << 32) >> 32;	// MULT, MULTU
					HI = (RSbus * RTbus) >> 32;
	 `select_fp_divu:
      `select_fp_div:	LO = RSbus / RTbus;	// DIV, DIVU
					HI = RSbus % RTbus;
   endcase
  end

//-------------------------------------------------------------------

endmodule
